package cn.chengpengper.seckill.order.application.event.handler;

import cn.chengpengper.seckill.order.domain.event.SeckillOrderEvent;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.event.EventHandler;
import com.alibaba.cola.event.EventHandlerI;
import com.alibaba.fastjson.JSON;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author chengpeng.hu
 */
@Slf4j
@EventHandler
@RequiredArgsConstructor
public class SeckillOrderEventHandler implements EventHandlerI<Response, SeckillOrderEvent> {

    @Override
    public Response execute(SeckillOrderEvent seckillOrderEvent) {
        log.info("SeckillOrderEventHandler|接收订单事件|{}", JSON.toJSON(seckillOrderEvent));
        if (seckillOrderEvent.getId() == null){
            log.info("SeckillOrderEventHandler|订单参数错误");
            return Response.buildSuccess();
        }
        return Response.buildSuccess();
    }
}
